﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class MainMenuManager : MonoBehaviour {

    //获取开始按钮
    public Button btn_start;
    //获取设置按钮
    public Button btn_rank;
    //获取问题按钮
    public Button btn_question;
    //获取退出按钮
    public Button btn_exit;
    //获取游戏信息
    public GameInfo _gameInfo;
    //获取游戏帮助列表
    public Image panel_question;
    //获取帮助列表返回按钮
    public Button btn_questionBack;
    //获取游戏排名列表
    public Image panel_rank;
    //获取游戏排名Text
    public Text rankText;
    //获取排名列表返回按钮
    public Button btn_rankBack;
	// Use this for initialization
	void Start () {
        btn_start.onClick.AddListener(() => {
            //Application.DontDestroyOnLoad(_gameInfo.gameObject);
            if (GameInfo._instance._scoreDic.Count>0)
            {
                PlayerPrefs.SetInt("bestScore", GameInfo._instance.GetBestScore());
            }
            Application.LoadLevel("GameScene");
        });
        btn_rank.onClick.AddListener(() =>
        {
            GameInfo._instance.SendMessage("GetRankScore");
            rankText.text = GameInfo._instance.GetRankToString();
            panel_rank.gameObject.SetActive(true);
        });

        btn_rankBack.onClick.AddListener(() =>
        {
            panel_rank.gameObject.SetActive(false);
        });
        btn_question.onClick.AddListener(() => {
            panel_question.gameObject.SetActive(true);
        });

        btn_questionBack.onClick.AddListener(() =>
        {
            panel_question.gameObject.SetActive(false);
        });

        btn_exit.onClick.AddListener(() => {
            GameInfo._instance.SaveInfo();
            PlayerPrefs.DeleteAll();
            Application.Quit();
        });
	}
	
	// Update is called once per frame
	void Update () {
	
	}
}
